import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';

class DelInputWidget extends StatelessWidget {
  final String hintText;
  final IconData icon;
  final Function(String) onChanged;
  final bool isPassword;
  final bool isShowDelIcon;
  final TextEditingController controller;
  DelInputWidget({this.icon, this.onChanged, this.isPassword = false, this.hintText, this.controller, this.isShowDelIcon = false});

  @override
  Widget build(BuildContext context) {
    return TextField(
      controller: controller,
      decoration: InputDecoration(
        suffixIcon: IconButton(
          onPressed: () {},
          icon: isShowDelIcon
              ? IconButton(
                  icon: Icon(
                    Icons.cancel,
                    color: Color(0xFFcccccc),
                  ),
                  onPressed: () {
                    controller.text = "";
                  },
                )
              : Text(""),
        ),
        focusedBorder: OutlineInputBorder(
          borderSide: BorderSide(color: Colors.blue),
          borderRadius: BorderRadius.all(Radius.circular(10)),
        ),
        enabledBorder: OutlineInputBorder(
          borderSide: BorderSide(color: Colors.black.withOpacity(0.6)),
          borderRadius: BorderRadius.all(Radius.circular(10)),
        ),
        contentPadding: EdgeInsets.all(13),
        hintText: hintText,
        hintStyle: TextStyle(color: Colors.black38),
        border: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none),
        filled: true,
        fillColor: Color(0xFFFFFFFF),
        prefixIcon: icon != null ? Icon(icon) : null,
      ),
      inputFormatters: [LengthLimitingTextInputFormatter(20)],
      onChanged: onChanged,
      obscureText: isPassword,
    );
  }
}
